import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
import Index from '../views/Index.vue'
import BlogEdit from '../views/BlogEdit.vue'
import BlogDetail from '../views/BlogDetail.vue'
import BlogAdd from '../views/BlogAdd.vue'
import MyIntroduce from '../views/MyIntroduce.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'anyi',
    redirect: {name: "Index"},
    meta:{
      title:"安逸i"
    }
  },
  {
    path: '/index',
    name: 'Index',
    component: Index,
    meta:{
      title:"安逸i"
    }
  },
  {
    path: '/login',
    name: 'Login',
    component: Login,
    meta:{
      title:"登录博客"
    }
  },
  {
    path: '/blog/add',
    name: 'BlogAdd',
    component: BlogAdd,
    meta: { 
      requireAuth: true,
      title:"发表博客"
    }
  },
  {
    path: '/blog/:blogId',
    name: 'BlogDetail',
    component: BlogDetail,
    meta: "博客详情"
  },
  {
    path: '/blog/:blogId/edit',
    name: 'BlogEdit',
    component: BlogEdit,
    meta: {
      requireAuth: true,
      title:"编辑博客"
    }
  },
  {
    path: '/user/me',
    name: 'MyIntroduce',
    component: MyIntroduce,
    meta: {
      title:"个人简介"
    }
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
